
package companyadministration;
import javax.persistence.EntityManager;
import model.DBManager;
import model.Paraggelia;

public class ListParagelliesForm extends javax.swing.JFrame {

    /**
     * Creates new form ListParagelliesForm
     */
    public ListParagelliesForm() {
        em = DBManager.em;
        if (!em.getTransaction().isActive()) { 
            em.getTransaction().begin();
        }
        initComponents();
        // Το παράθυρο ανοίγει στο κέντρο της οθόνης
        setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        paraggeliaQuery = java.beans.Beans.isDesignTime() ? null : em.createQuery("SELECT p FROM Paraggelia p");
        paraggeliaList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : org.jdesktop.observablecollections.ObservableCollections.observableList(paraggeliaQuery.getResultList());
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1NeaParaggelia = new javax.swing.JButton();
        jButton1EpexergasiaParaggelias = new javax.swing.JButton();
        jButton1DiagrafiParaggelias = new javax.swing.JButton();
        jButton1Akiro = new javax.swing.JButton();
        jButton1Apothikeusi = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setText("ΠΑΡΑΓΕΛΛΙΕΣ");

        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, paraggeliaList, jTable1, "paragelliesBind");
        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${pelatisid}"));
        columnBinding.setColumnName("Pelatisid");
        columnBinding.setColumnClass(model.Pelatis.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${payoff}"));
        columnBinding.setColumnName("Payoff");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${eidos}"));
        columnBinding.setColumnName("Eidos");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${typepack}"));
        columnBinding.setColumnName("Typepack");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${dateproduct}"));
        columnBinding.setColumnName("Dateproduct");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${perioxi}"));
        columnBinding.setColumnName("Perioxi");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${siskeyasia}"));
        columnBinding.setColumnName("Siskeyasia");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${price}"));
        columnBinding.setColumnName("Price");
        columnBinding.setColumnClass(Double.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${posotita}"));
        columnBinding.setColumnName("Posotita");
        columnBinding.setColumnClass(Double.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${numorder}"));
        columnBinding.setColumnName("Numorder");
        columnBinding.setColumnClass(Integer.class);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();

        jScrollPane1.setViewportView(jTable1);

        jButton1NeaParaggelia.setText("Νέα Παραγγελία");
        jButton1NeaParaggelia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1NeaParaggeliaActionPerformed(evt);
            }
        });

        jButton1EpexergasiaParaggelias.setText("Επεξεργασία Παραγγελίας");
        jButton1EpexergasiaParaggelias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1EpexergasiaParaggeliasActionPerformed(evt);
            }
        });

        jButton1DiagrafiParaggelias.setText("Διαγραφή Παραγγελίας");

        jButton1Akiro.setText("Άκυρο");

        jButton1Apothikeusi.setText("Αποθήκευση");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 731, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jButton1NeaParaggelia)
                                .addGap(18, 18, 18)
                                .addComponent(jButton1EpexergasiaParaggelias)
                                .addGap(18, 18, 18)
                                .addComponent(jButton1DiagrafiParaggelias))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jButton1Akiro)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButton1Apothikeusi)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1NeaParaggelia)
                    .addComponent(jButton1EpexergasiaParaggelias)
                    .addComponent(jButton1DiagrafiParaggelias))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 55, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1Akiro)
                    .addComponent(jButton1Apothikeusi))
                .addContainerGap())
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1NeaParaggeliaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1NeaParaggeliaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1NeaParaggeliaActionPerformed

    private void jButton1EpexergasiaParaggeliasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1EpexergasiaParaggeliasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1EpexergasiaParaggeliasActionPerformed

    /**
     * @param args the command line arguments
     */
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1Akiro;
    private javax.swing.JButton jButton1Apothikeusi;
    private javax.swing.JButton jButton1DiagrafiParaggelias;
    private javax.swing.JButton jButton1EpexergasiaParaggelias;
    private javax.swing.JButton jButton1NeaParaggelia;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private java.util.List<model.Paraggelia> paraggeliaList;
    private javax.persistence.Query paraggeliaQuery;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
EntityManager em;
}
